package com.example.springbootswagger2.common;

public class RestResultFactory {

    public static <T> RestResult<T> createResult(int status, T data, String message) {
        RestResult<T> result = RestResult.newInstance();
        result.setStatus(status);
        result.setData(data);
        result.setMessage(message);
        return result;
    }

    public static <T> RestResult<T> createSuccessResult(T data) {
        return createResult(0, data, null);
    }

    public static <T> RestResult<T> createSuccessResult(T data, String msg) {
        return createResult(0, data, msg);
    }

    public static <T> RestResult<T> createSuccessResult() {
        return RestResultFactory.createSuccessResult(null);
    }

    public static <T> RestResult<T> createErrorResult(String message) {
        return createResult(3, null, message);
    }

    public static <T> RestResult<T> createErrorResult(T data, String message) {
        return createResult(3, data, message);
    }
}

